package com.zys.el.time.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zys.el.time.service.redis.ScrollDetail;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.ZoneOffset;

/**
 * 帖子
 * @TableName thinking
 */
@TableName(value ="thinking")
@Data
@ApiModel("帖子实体类")
public class Thinking implements Serializable, ScrollDetail {
    /**
     * 帖子id
     */
    @TableId
    @ApiModelProperty("帖子id")
    private Long thinkingId;

    /**
     * 频道id
     */
    @ApiModelProperty("频道id")
    private Long channelId;

    /**
     * 发布者id
     */
    @ApiModelProperty("发布者id")
    private Long userId;

    /**
     * 帖子正文
     */
    @ApiModelProperty("帖子正文")
    private String text;

    /**
     * 创建时间
     */
    @ApiModelProperty("创建时间")
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @ApiModelProperty("更新时间")
    private LocalDateTime updateTime;

    /**
     * 状态(1：正常，2：审核中，3：未过审)
     */
    @ApiModelProperty(value = "状态", notes = "1：正常，2：审核中，3：未过审")
    private Integer status;

    /**
     * 是否删除(0-未删, 1-已删)
     */
    @TableLogic
    @TableField(select = false)
    private Integer isDeleted;

    @TableField(exist = false)
    private static final long serialVersionUID = 1L;

    @Override
    public long getScore() {
        return this.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli();
    }

    @Override
    public long getId() {
        return this.thinkingId;
    }
}